#ifndef STRAY_GRAPHICS_MANAGER_H
#define STRAY_GRAPHICS_MANAGER_H

#include "../Common.h"
#include "../Object/Singleton.h"
#include "../SmartPtr/IntrusivePtr.h"
#include "../Window/Window.h"
#include "Device.h"
#include "Context.h"
#include "View.h"
#include "Format.h"

namespace Stray {
namespace Core {

namespace Graphics {

struct GraphicsSet
{
	DevicePtr	spDevice_;
	ContextPtr	spContext_;
	ViewPtr		spView_;
};

enum GraphicsAPI
{
	GAPI_DIRECTX9,
	GAPI_DIRECTX11,
	GAPI_OPENGL,
};

struct DisplayMode
{
	Stray::Uint32 width_;
	Stray::Uint32 height_;
};

typedef Stray::Vector<Stray::Core::Graphics::DisplayMode>::type DisplayModeArray;

enum MSAAQuality
{
	MSAA_NONE,
	MSAA_X2,
	MSAA_X4,

	MSAA_MAX,
};

struct GraphicsParameter
{
	GraphicsAPI			api_;
	DisplayMode			displayMode_;
	DepthBufferFormat	depthBufferFormat_;
	MSAAQuality			msaa_;
	Stray::Bool			isFullScreen_;
};

class GraphicsManagerImpl
{
	friend class Stray::SingletonHolder<GraphicsManagerImpl>;
public:
	void initialize();
	void terminate();

	DisplayModeArray getEnableDisplayModes();
	GraphicsSet createGraphicsSet(const WindowHandle& handle, const GraphicsParameter& param);
private:
	
	Stray::Bool hasInitialized_;

private:
	GraphicsManagerImpl():hasInitialized_(Stray::B_FALSE){}
	GraphicsManagerImpl(const GraphicsManagerImpl&);
	~GraphicsManagerImpl(){}
	const GraphicsManagerImpl& operator =(const GraphicsManagerImpl&);
};

typedef Stray::SingletonHolder<GraphicsManagerImpl> GraphicsManager;

}
}
}

#endif